package com.xuyiwei.mayi.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * Created by xuyiwei on 2019/4/18.
 */
@Aspect
@Component
public class Aop11 {
    @Before("execution(* com.xuyiwei.mayi.controller.UserController.add(..))")
    public void begin() {
        System.out.println("前置通知");
    }

    @After("execution(* com.xuyiwei.mayi.controller.UserController.add(..))")
    public void commit() {
        System.out.println("后置通知");
    }

    @AfterReturning("execution(* com.xuyiwei.mayi.controller.UserController.add(..))")
    public void afterReturning() {
        System.out.println("运行通知");
    }

    @AfterThrowing("execution(* com.xuyiwei.mayi.controller.UserController.add(..))")
    public void afterThrowing() {
        System.out.println("异常通知");
    }

    @Around("execution(* com.xuyiwei.mayi.controller.UserController.add(..))")
    public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("我是环绕通知-前");
        proceedingJoinPoint.proceed();
        System.out.println("我是环绕通知-后");
    }

}

